package view;

import com.trolltech.qt.gui.QDialog;
import com.trolltech.qt.gui.QHBoxLayout;
import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QLineEdit;
import com.trolltech.qt.gui.QPushButton;

public class RunCase2Dialog extends QDialog {
	
    private final QLabel label;
    private final QLineEdit lineEdit;
    private final QPushButton okButton;
	
	public RunCase2Dialog(final MainWindow monkeyWindow) {
		super(monkeyWindow);
		this.setModal(true);
		
		
		label = new QLabel("Set Banana Movement:");
//      lineEdit = new QLineEdit();
      lineEdit = new QLineEdit();
      
      lineEdit.setInputMask("99");//non funziona tanto bene...
//      lineEdit.setValidator(new QIntValidator(lineEdit));
//      lineEdit.setText("1000");

      okButton = new QPushButton("Ok");
      okButton.setDefault(true);
      

      final QHBoxLayout mainLayout = new QHBoxLayout();
      mainLayout.addWidget(label);
      mainLayout.addWidget(lineEdit);
      mainLayout.addWidget(okButton);

      setLayout(mainLayout);
      
      okButton.clicked.connect(this,"buttonClicked()");
	
      setWindowTitle("Set Movement Time");

	}
	
	@SuppressWarnings("unused")
	private void buttonClicked() {
		
		if (!lineEdit.text().isEmpty()&& Integer.parseInt(lineEdit.text())!= 0) {
//			((MainWindow)parent()).getMenuBarControl().setBananaMovementTime(Integer.parseInt(lineEdit.text()));
			this.close();
		}
	}

}
